<?php
#程序级配置
error_reporting(E_ALL);
ini_set('date.timezone','PRC');
define('ROOT',dirname(dirname(dirname(__FILE__))));					//PHP站点架设的根路径
define('ROOT_Application',dirname(dirname(__FILE__)));				//管理应用系统在PHP站点中的路径
header("Content-type:text/html;charset=utf-8");

/**
 * 导入程序库
 */
function Import_Library($name)
{
    switch ($name)
    {
        //单元素接口约定
        case 'ISingleton':
            include_once(ROOT.'/library/interface/singleton.php');
        break;
        //配置文件读取接口约定
        case 'IConfig_Get':
            include_once(ROOT.'/library/interface/config.get.php');
        break;
        //配置文件读取并设置接口约定
        case 'IConfig_Set':
            include_once(ROOT.'/library/interface/config.set.php');
        break;
        //函数库
        case 'Functions':
            include_once(ROOT.'/library/function.php');
        break;
        //Smarty类库
        case 'Smarty':
            include_once(ROOT.'/library/package/smarty/smarty.class.php');
        break;
        //验证码类SimpleCaptcha
        case 'SimpleCaptcha':
            include_once(ROOT.'/library/package/captcha/captcha.php');
        break;
        //session操作
        case 'Session':
            include_once(ROOT.'/library/session.php');
        break;
        //Cookie操作类
        case 'Cookie':
            include_once(ROOT.'/library/cookie.php');
        break;
        //过滤类
        case 'Filter':
            include_once(ROOT.'/library/filter.php');
        //匹配操作类
        case 'Match':
            include_once(ROOT.'/library/match.php');
        break;
        //上传类
        case 'Upload':
            include_once(ROOT.'/library/package/file/upload.php');
        break;
        //DB类库
        case 'DB_IAdvanced':
            include_once(ROOT.'/library/package/db/iadvanced.php');
        break;
        case 'DB':
            include_once(ROOT.'/library/package/db/db.php');
        break;
        case 'DB_MySQL':
            include_once(ROOT.'/library/package/db/mysql.php');
        break;
        case 'EPDO':
            include_once(ROOT.'/library/package/db/epdo.php');
        break;
        case 'Functions':
            include_once(ROOT.'/library/function.php');
        break;
        //发送邮件类
        case 'Email':
            include_once(ROOT.'/library/email.php');
        break;		
    }
}
spl_autoload_register('Import_Library');
#分页类
function Import_Pager($name)
{
    switch($name)
    {
        //类结构
        case 'Pager':
            include_once(ROOT.'/library/package/pager/pager.php');
        break;
        //类工厂
        case 'PagerFactory':
            include_once(ROOT.'/library/package/pager/factory.php');
        break;
        //重写器
        case 'PagerRewrite':
            include_once(ROOT.'/library/package/pager/rewrite.php');
        break;
        //具体类
        default:
        {
            if(substr($name,0,6)=='Pager_')
            {
                $path=ROOT.'/library/package/pager/'.strtolower($name).'.php';
                include_once($path);
            }
        }
    }
}
spl_autoload_register('Import_Pager');



/**
 * 导入网站核心类
 */
#配置文件
function Import_Application($name) 
{
    switch($name)
    {
        //程序配置
        case 'Config':
            include_once(ROOT.'/core/config.php');
        break;
    }
}
spl_autoload_register('Import_Application');
#静化器
function Import_Staticizer($name) 
{
    switch($name)
    {
        case 'Staticizer':
            include_once(ROOT.'/core/staticizer/staticizer.php');
        break;
        case 'StaticizerFactory':
            include_once(ROOT.'/core/staticizer/staticizer.factory.php');
        break;
        default:
        {
            if(substr($name,0,11)=='Staticizer_')
            {
                $path='';
                {
                    foreach(explode('_', $name) as $vaue)
                    {
                        $path=($path.'/'.strtolower($vaue));
                    }
                }
                $path=ROOT.'/core'.$path.'.php';
                include_once($path);
            }
        }
    }
}
spl_autoload_register('Import_Staticizer');
#导入系统应用类
function Import_EntityObject($name)
{
    switch($name)
    {
        case 'User':
            include_once(ROOT.'/admin/core/eo/user.php');
        break;

        case 'Permission':
            include_once(ROOT.'/admin/core/eo/permission.php');
        break;
    }
}
spl_autoload_register('Import_EntityObject');

/**
 * 导入应用实体类
 */
function Import_Application_EO($name)
{
    switch($name)
    {
        case 'Account':
            include_once(ROOT . '/core/eo/account.php');
        break;
    }
}
spl_autoload_register('Import_Application_EO');
?>